import {Injectable} from '@angular/core';
import {
  CanActivate, Router,
  ActivatedRouteSnapshot,
  RouterStateSnapshot
}                           from '@angular/router';
import {user} from '../user/user.service';
@Injectable()
export class StudentGuard implements CanActivate{
  constructor(){

  }
  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean|Promise<boolean>{
    if(!user.isSignIn) {
      console.log(route);
       user.redirectTo=state.url;
    }
    return user.userType === 1;
  }
}
